﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Data.SQLite;

namespace HZToPY
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var file = Console.ReadLine();
            SQLiteConnection connection = new SQLiteConnection("Data Source=" + file);
            connection.Open();
            SQLiteCommand command = new SQLiteCommand("select * from PERSON", connection);

            var reader = command.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var name = reader["NAME"].ToString();
                    var id = reader["ID"].ToString();
                    var py = ConvertHZToPY.ToChineseSpell(name);
                    SQLiteCommand insertPY = new SQLiteCommand(
                        string.Format("update PERSON set PY = '{0}' where ID='{1}'", py, id),
                        connection);
                    insertPY.ExecuteNonQuery();

                    Console.WriteLine("Convert '{0}' to '{1}'", name, py);
                }
            }

            reader.Close();
            connection.Close();
        }
    }
}